const fs = require('fs');
const path = require('path');
var arr = process.argv;
var filePath = path.join(__dirname, arr[2]);

function deleteFile(url) {
    if (fs.existsSync(url)) {
        let stat = fs.statSync(url);
        if (stat.isFile()) {
            fs.unlinkSync(url, (err) => {
                if (err) {
                    console.log(err);
                }
            });
        } else if (stat.isDirectory()) {
            var content = fs.readdirSync(url);
            for (var i = 0; i < content.length; i++) {
                deleteFile(path.join(url, content[i]));
            }
            fs.rmdirSync(url);
        }
    } else {
        console.log('文件目录不存在！');
    }
}

deleteFile(filePath);